package com.baiyang.server.config.provider;

import java.util.Collection;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.baiyang.server.model.system.User;

public class UserDetail implements UserDetails{
	private static final long serialVersionUID = 1L;
	private String userName;
	private String password;
	private User user;
	private List<Authority> authorities;
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		// TODO Auto-generated method stub
		return authorities;
	}

	@Override
	public String getPassword() {
		// TODO Auto-generated method stub
		return password;
	}

	@Override
	public String getUsername() {
		// TODO Auto-generated method stub
		return userName;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public void setAuthorities(List<Authority> authorities) {
		this.authorities = authorities;
	}
	@Override
	public boolean isAccountNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isEnabled() {
		// TODO Auto-generated method stub
		return true;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}

class Authority implements GrantedAuthority{
	private static final long serialVersionUID = 1L;
	private String authority;
	@Override
	public String getAuthority() {
		// TODO Auto-generated method stub
		return authority;
	}
	public Authority(String authority) {
		this.authority = authority;
	}
	@Override
	public String toString() {
		return "Authority [authority=" + authority + "]";
	}
	
}
